/**
 * <p>
 * Class generated using net.openmaximo.maven.plugins:maven-maximodev-plugin.
 * </p>
 */
package ${package};

import java.rmi.RemoteException;

import psdi.app.system.CrontaskParamInfo;
import psdi.security.UserInfo;
import psdi.server.CronTask;
import psdi.server.MXServer;
import psdi.server.MXServerRemote;
import psdi.server.SimpleCronTask;
import psdi.util.MXException;

/**
 * <p>
 * Class for the ${className} Crontask.
 * </p>
 */
public class ${className} extends ${parentClass} implements CronTask {
  /**
   * <p>
   * CRONTASK parameters
   * </p>
   */
  private static CrontaskParamInfo params[];
  
  /**
   * 
   */
  private UserInfo userInfo;
  
  /**
   * 
   */
  static {
    params = null;
    // TODO Auto-generated static stub
    params = new CrontaskParamInfo[1];
    params[0] = new CrontaskParamInfo();
    params[0].setName("SAMPLEPARAMETER");
    params[0].setDescription("Sample parameter.");
  }
  
  /**
   * <p>
   * Will have the sample parameter value.
   * </p>
   */
  private String sampleParameter = null;

  /**
   * <p>
   * Constructor por defecto.
   * </p>
   * 
   */
  public ${className}() {
  }
  
  /**
   * <p>Inits the CRONTASK.</p>
   */
  public void init() throws MXException {
    super.init();
    userInfo = getRunasUserInfo();
  }

  /**
   * <p>Checks if the CRONTASK respects it's requirements to run.</p>
   * @param mxServR
   * @return
   */
  public boolean isOKToRun(MXServerRemote mxServR) {
    // TODO Auto-generated method stub
    try {
      this.sampleParameter = getParamAsString("SAMPLEPARAMETER");
      if (super.isOKToRun(mxServR)) {
        // TODO Auto-generated method stub
        return true;
      }
    } catch (RemoteException e) {
      // TODO Auto-generated method stub
    } catch (MXException e) {
      // TODO Auto-generated method stub
    }
    return false;
  }

  /**
   * <p>
   * Starts the task.
   * </p>
   */
  public void start() {
    // TODO Auto-generated method stub
    super.start();
    try {
      loadXMLLocation = getParamAsString("SAMPLEPARAMETER");
      // TODO Auto-generated method stub
    } catch (Exception exception) {
      getCronTaskLogger().fatal(exception.getMessage(), exception);
    }
  }

  /**
   * <p>
   * Action executed by the CRONTASK.
   * </p>
   */
  public void cronAction() {
    // TODO Auto-generated method stub
    MXServer mxServer = null;
    try {
      mxServer = MXServer.getMXServer();
      // TODO Auto-generated method stub
    } catch (RemoteException exception) {
      getCronTaskLogger().fatal(exception.getMessage(), exception);
      return;
    }
  }
  
  /**
   * <p>
   * Get the CRONTASK parameters.
   * </p>
   */
  public CrontaskParamInfo[] getParameters() throws MXException,
      RemoteException {
    return params;
  }
}
